import scala.io.Source

def getLineWidth(x: String): Int = {
  x.length.toString.length
}

if ( args.length > 0 ) {
  val lines = Source.fromFile(args(0)).getLines.toList
//  print(lines)
  val longestLine = lines.reduceLeft(
    (a, b) => if ( a.length > b.length ) a else b
  )
  val maxWidth = getLineWidth(longestLine)
  for (line <- lines) {
    val charNum = line.length
    val empty = " " * (maxWidth - getLineWidth(line))
    println(empty + charNum + " | " + line)
  }
}
else {
  Console.err.println("no args!")
}
